<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box {
        width: 400px;

        background-color: aqua;
        position: fixed;
        right: 0;
        bottom: 0;
      }
      span {
        font-size: 50px;
        position: absolute;
        right: 0;
        top: -25px;
        cursor: pointer;
      }
      .box_top {
        width: 100%;
        height: 200px;
        text-align: center;
        line-height: 200px;
        color: aliceblue;
        font-size: 30px;
      }
      .box_bottom {
        width: 100%;
        height: 200px;
        text-align: center;
        line-height: 200px;
        color: rgb(197, 42, 211);
        font-size: 30px;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <span>x</span>
      <div class="box_top">我是上部分</div>
      <div class="box_bottom">我是下部分</div>
    </div>

    <script>
      $(function () {
        $("span").click(function () {
          $(".box_bottom").animate(
            {
              height: 0,
            },
            500,
            function () {
              $(".box").animate(
                {
                  width: 0,
                  opacity: 0,
                },
                500
              );
            }
          );
        });
      });
    </script>
  </body>
</html>
